package com.user.action;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.user.entity.User;
import org.apache.struts2.interceptor.SessionAware;

import java.util.Map;

public class UserAction extends ActionSupport implements ModelDriven<User>,SessionAware{
    private Map<String,Object> session=null;
    private User user=new User();//get和set可省略
    private String es;

    public String getEs() {
        return es;
    }

    public void setEs(String es) {
        this.es = es;
    }

    public String login(){
        es="注册成功";
        if("admin".equals(user.getuName())&&"123456".equals(user.getuPassword())){
            session.put("user",user);
            return "loginSUCCESS";
        }
        return this.ERROR;
    }
    public String landing(){
        es="登陆成功";
        return "landingSUCCESS";
    }
    public String update(){
        es="更新成功";
        return "updateSUCCESS";
    }
    public String select(){
        es="查询成功";
        return "selectSUCCESS";
    }

    public User getModel() {
        return this.user;
    }

    public void setSession(Map<String, Object> map) {
        session=map;
    }
}
